home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / packer / xpkilzr / source / cbitio.h < prev    next >
Text File  |  1996-02-26  |  4KB  |  77 lines

  1.  
  2. /**
  3.   *  Este fichero ha sido diseqado para manejar de forma estandar
  4.   * las entradas salidas que son necesarias de forma binaria
  5.   *  Se ha intentado optimizar al maximo para aumentar la velocidad
  6.   * sin preocuparse si el origen o destino es memoria o un fichero
  7.   *
  8.   **/
  9.  
  10.  
  11. /*  compress InputByte  , OutputBits , OutputBit                    */
  12. /*  expand   OutputByte , InputBits  , InputBit                     */
  13.  
  14. /*    START of COMPRESS                                             */
  15.  
  16. /*          UBYTE   endoffile                                       */
  17. /*          CHARS   *inpb                                           */
  18. /*          CHARS   *endinp                                         */
  19. /*          CHARS   *outb                                           */
  20. /*          CHARS   *endout                                         */
  21. /*          ULONG   ioaux                                           */
  22.  
  23. #define InitOutput()    {                                         \
  24.                         outb      = (CHARS *)xpar->OutBuf;        \
  25.                         *outb     = 0;                            \
  26.                         outmask   = 0x80;                         \
  27.                         endout    = (CHARS *)                     \
  28.                       ((long)xpar->OutBuf+(long)xpar->OutBufLen); \
  29.                         }
  30.  
  31. #define InitInput()     {                                         \
  32.                         inpb      = (CHARS *)xpar->InBuf;         \
  33.                         endinp    = (CHARS *)                     \
  34.                       ((long)xpar->InBuf+(long)xpar->InLen);      \
  35.                         }
  36.  
  37.  
  38. #define OutputBit( bit )  {                                       \
  39.                           if ( bit )                              \
  40.                             *outb |= outmask;                     \
  41.                           outmask >>= 1;                          \
  42.                           if ( !outmask  )                        \
  43.                             {                                     \
  44.                             if( ++outb >= endout )                \
  45.                               return( XPKERR_EXPANSION );         \
  46.                             *outb   = 0;                          \
  47.                             outmask = 0x80;                       \
  48.                             }                                     \
  49.                           }
  50.  
  51. #define OutputBits( code, count ) {                               \
  52.                           ioaux = 1L << ( count - 1 );            \
  53.                           while ( ioaux != 0)                     \
  54.                             {                                     \
  55.                             if ( code & ioaux )                   \
  56.                               *outb |= outmask;                   \
  57.                             outmask >>= 1;                        \
  58.                             if ( !outmask  )                      \
  59.                               {                                   \
  60.                               if( ++outb >= endout )              \
  61.                                 return( XPKERR_EXPANSION );       \
  62.                               *outb   = 0;                        \
  63.                               outmask = 0x80;                     \
  64.                               }                                   \
  65.                             ioaux >>= 1;                          \
  66.                             }                                     \
  67.                           } 
  68.  
  69. #define InputByte(  )     {                                       \
  70.                           if(inpb++ >=endinp )                    \
  71.                             endoffile = 1;                        \
  72.                           }
  73.  
  74. #define EndOfFile()       ( endoffile )
  75.  
  76. /*************************** End of BITIO.C **************************/
  77.